package LeetCode;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2024/6/5.
//
//https://leetcode.cn/problems/pascals-triangle-ii/description/
public class 杨辉三角II {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        List<Integer> res = getRow(scan.nextInt());
        System.out.println(res);
    }

    public static List<Integer> getRow(int rowIndex) {
        List<List<Integer>> res = new ArrayList<>();
        res.add(new ArrayList<>());
        res.get(0).add(1);
        if(rowIndex == 0)return res.get(0);
        for (int i = 1; i <= rowIndex; i++) {
            res.add(new ArrayList<>());
            res.get(i).add(1);
            for (int j = 1; j < i; j++) {
                res.get(i).add(res.get(i-1).get(j-1) + res.get(i-1).get(j));
            }
            res.get(i).add(1);
        }
        return res.get(rowIndex);
    }
}
